﻿@model WaiGaoQiaoWeb.Models.ConsumptionPeriodsVM
@{
    ViewBag.Title = "ConsumptionPeriodsIndex";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Head
{
    <script type="text/javascript" language="javascript">
        var maiheight = document.documentElement.clientHeight;
        var mainWidth = document.documentElement.clientWidth - 3; // 减去边框和左边的宽度
        var gh = maiheight - 213;
        $(document).ready(function () {
            var option = {
                height: maiheight - 80,
                width: $(document).width(),
                url: '@Url.Action("GetConsumptionPeriodsList")', // 参数要放在）括号的外面
                dataType: 'json',
                colModel: [
                    { display: '编号', name: 'PeriodCode', width: 100, sortable: false, hide: true, align: 'left', iskey: true },
                    { display: '时段名称', name: 'PeriodName', width: 100, sortable: false, hide: false, align: 'left' },
					{ display: '开始时间', name: 'BeginTime', width: 100, sortable: false, hide: false, align: 'left' },
                    { display: '结束时间', name: 'EndTime', width: 100, sortable: false, hide: false, align: 'left' },
                    { display: '是否跨天', name: 'NextDay', width: 50, sortable: false, hide: false, align: 'left' }
				],
                buttons: [
                            { name: 'Edit', displayname: "修改", title: "修改", bclass: 'edit', onpress: toolbarItemEdit_onclick },
							{ separator: true }
						 ],
                title: false,
                singleselected: false,
                usepager: true,
                resizable: true,
                page: 1, //默认当前页  
                total: 1, //总页面数  
                useRp: true, //是否可以动态设置每页显示的结果数  
                rp: 20, // 每页默认的结果数  
                rpOptions: [10, 15, 20], //可选择设定的每页结果数
                showcheckbox: true,
                selectedonclick: true,
                rowbinddata: true,
                hideOnSubmit: true, //隐藏提交  
                autoload: true
            };
            $("#ConsumptionPeriodsList").flexigrid(option);

            function toolbarItemEdit_onclick(cmd, grid) {
                var items = $("#ConsumptionPeriodsList").getSelectedRows();
                if (items.length == 0) {
                    showLoadingMsg("请选择要编辑的时段!", { left: 400, top: 6 }, true, 3000);
                    return false;
                }
                if (items.length > 1) {
                    showLoadingMsg("只能选择一个要编辑的时段!", { left: 400, top: 6 }, true, 3000);
                    return false;
                }
                var ID = items[0][0];
                OpenModelWindow('@Url.Action("EditConsumptionPeriods")?id=' + ID,
                 { width: 450, height: 300, caption: "修改时段", onclose: refresh });
            }
            function refreshGrid() {
                $("#ConsumptionPeriodsList").flexReload();
            }
            function refresh() {
                showLoadingMsg("保存成功", { left: 200, top: 6 }, true, 3000);
                $("#ConsumptionPeriodsList").flexReload();
            }
        });
    </script>
}
<div id="container_sx">
    <div id="mainContent">
        <table id="ConsumptionPeriodsList" style="display: none;">
        </table>
    </div>
</div>